$(".publish").click(function () {
  const name = $(".input-box .name").val()
  const content = $(".input-box .content").val()
  if (!name || !content) {
    alert("昵称和内容不能为空");
    return;
  }

  if ($(".ni-ming").prop('checked')) {
    addHistory("路人甲", "下午05:06:21", content);
  } else {
    addHistory(name, "下午05:06:21", content);
  }

});

function addHistory(name, time, content) {
  const history = $(".history");
  const top = $(`<div class="top"></div>`);
  const nameEle = $(`<span class="name">${name}</span>`);
  const timeEle = $(`<span class="time">${time}</span>`);
  top.append(nameEle).append(timeEle);
  const contentEle = $(`<div class="content">${content}</div>`);
  history.append(top).append(contentEle);
}
